
using System;
using System.IO;
 
using iTextSharp.text;
using iTextSharp.text.xml;
using iTextSharp.text.pdf;
 
public class Sharp0702
{
    public static void _Main()
    {
        Console.WriteLine("Chapter 7 example 2: parsing the result of example 1");
        // step 1: creation of a document-object
        Document document = new Document();
        try
        {
            // step 2:
            // we create a writer that listens to the document
            // and directs a XML-stream to a file
            PdfWriter.GetInstance(document, new FileStream("Sharp0702.pdf", FileMode.Create));
            // step 3: we create a parser
            ITextHandler h = new ITextHandler(document);
            // step 4: we parse the document
            h.Parse("Sharp0701.xml");
        }
        catch (Exception e)
        {
            Console.Error.WriteLine(e.StackTrace);
            Console.Error.WriteLine(e.Message);
        }
    }
}